package com.stek.panel;

import java.util.ArrayList;

import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;

import com.google.android.gms.ads.AdView;
import com.stek.R;
import com.stek.base.BaseOverLayActivity;
import com.stek.utils.AdMode;

public class PanelActivity extends BaseOverLayActivity {
	private ViewPager mViewPager;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_panel);
		mViewPager = (ViewPager) findViewById(R.id.pager);
		PanelPagerAdapter adapter = new PanelPagerAdapter(
				getSupportFragmentManager());
		mViewPager.setAdapter(adapter);
		adView = (AdView) findViewById(R.id.admod);
		AdMode.init(adView);
	}


	@Override
	protected void initActionBar() {
		super.initActionBar();
		getSupportActionBar().setDisplayShowTitleEnabled(true);
		getSupportActionBar().setBackgroundDrawable(
				new ColorDrawable(getResources().getColor(R.color.transparent)));
	}


	private class PanelPagerAdapter extends FragmentStatePagerAdapter {
		private ArrayList<Fragment> fragments;

		public PanelPagerAdapter(FragmentManager fm) {
			super(fm);
			fragments = new ArrayList<Fragment>();
			fragments.add(PanelFrament.newInstance(PanelFrament.MAIN_PANEL,
					getString(R.string.main_panel)));
			fragments.add(PanelFrament.newInstance(PanelFrament.SUB_PANEL,
					getString(R.string.settings_panel)));
			fragments.add(PanelFrament.newInstance(PanelFrament.FAV_PANEL,
					getString(R.string.favorite_panel)));
		}

		@Override
		public CharSequence getPageTitle(int position) {
			return fragments.get(position).getArguments()
					.getString(PanelFrament.KEY_TITLE);
		}

		@Override
		public Fragment getItem(int arg0) {
			return fragments.get(arg0);
		}

		@Override
		public int getCount() {
			return 3;
		}

	}
}
